package eScrum.services.Impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import eScrum.dao.UserDao;
import eScrum.entities.User;
import eScrum.entities.UserSearchCriteria;
import eScrum.services.UserService;

@Transactional
public class UserServiceImpl implements UserService {

	private UserDao userDAO;

	public UserDao getUserDao() {
		return userDAO;
	}

	public void setUserDao(UserDao userDAO) {
		this.userDAO = userDAO;
	}

	public User saveOrUpdate(User u) {
		// logger.debug("saveOrUpdate");
		return this.userDAO.saveOrUpdate(u);
	}

	public User findUserByUserName(String username) {
		// logger.debug("findUserByUserName");
		return this.userDAO.exists(username);
	}

	public boolean signIn(String username, String password) {
		// logger.debug("signIn");
		return userDAO.signIn(username, password);
	}

	public List<User> findAll() {
		// logger.debug("findAll");
		return userDAO.findAll();
	}

	public void deleteUser(String id) {
		// logger.debug("deleteUser");
		this.userDAO.deleteUser(id);
	}

	public User findById(long id) {
		// logger.debug("findById");
		return this.userDAO.findById(id);
	}

	public List<User> findUsersByRange(int start, int count, UserSearchCriteria userSearchCriteria) {
	//	logger.debug("findUsersByRange");
		return userDAO.findUsersByRange(start, count, userSearchCriteria);
	}

	public long userSize(UserSearchCriteria userSearchCriteria) {
		
		return this.userDAO.userSize(userSearchCriteria);
	}

}
